package com.chenchao.reflection;

/**
 * @encoding : UTF-8
 * @Time : 2020/12/2 16:54
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.reflection.Test09.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 * 类加载器
 */
public class Test09 {
    public static void main(String[] args) {
        /*获取系统类加载器*/
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);
        //sun.misc.Launcher$AppClassLoader@18b4aac2

        /*获取系统类加载器的父类--》扩展类加载器*/
        ClassLoader parent = systemClassLoader.getParent();
        System.out.println(parent);
        //sun.misc.Launcher$ExtClassLoader@14ae5a5

        /*获取扩展类加载器的父类-->根加载器用c++写的获取不到*/
        ClassLoader parent1 = parent.getParent();
        System.out.println(parent1);
        //null

        /*测试自己的类是由什么加载器加载*/
        ClassLoader classLoader = Test09.class.getClassLoader();
        System.out.println(classLoader);
        //sun.misc.Launcher$AppClassLoader@18b4aac2

        /*测试JDK的类是由什么加载器加载的*/
        ClassLoader classLoader1 = Object.class.getClassLoader();
        System.out.println(classLoader1);
        //null

        /*获取类加载器可以加载的路径*/
        String property = System.getProperty("java.class.path");
        System.out.println(property);
        //其中包含了C:\mycode\newjava\javaSE\myjava01\src\lib\commons-io-2.8.0-sources.jar;
    }
}
